package action;

import java.util.List;

import biz.DoctorBiz;
import biz.UserBiz;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import entity.Doctor;

public class DoctorAction extends ActionSupport {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int doctorId;
	public int getDoctorId() {
		return doctorId;
	}

	public void setDoctorId(int doctorId) {
		this.doctorId = doctorId;
	}


	private String doctorNick;
	private String doctorPassword;
	private String doctorName;
	private int departmentId;
	private int doctorWorkId;
	private String doctorSex;
	private int doctorAge;
	private String doctorPhone;
	/*private DoctorBiz doctorBiz;
	
	public DoctorBiz getDoctorBiz() {
		return doctorBiz;
	}

	public void setDoctorBiz(DoctorBiz doctorBiz) {
		this.doctorBiz = doctorBiz;
	}*/

	public String getDoctorName() {
		return doctorName;
	}

	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}

	public int getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(int departmentId) {
		this.departmentId = departmentId;
	}

	public int getDoctorWorkId() {
		return doctorWorkId;
	}

	public void setDoctorWorkId(int doctorWorkId) {
		this.doctorWorkId = doctorWorkId;
	}

	public String getDoctorSex() {
		return doctorSex;
	}

	public void setDoctorSex(String doctorSex) {
		this.doctorSex = doctorSex;
	}

	public int getDoctorAge() {
		return doctorAge;
	}

	public void setDoctorAge(int doctorAge) {
		this.doctorAge = doctorAge;
	}

	public String getDoctorPhone() {
		return doctorPhone;
	}

	public void setDoctorPhone(String doctorPhone) {
		this.doctorPhone = doctorPhone;
	}

	public String getDoctorNick() {
		return doctorNick;
	}

	public void setDoctorNick(String doctorNick) {
		this.doctorNick = doctorNick;
	}

	public String getDoctorPassword() {
		return doctorPassword;
	}

	public void setDoctorPassword(String doctorPassword) {
		this.doctorPassword = doctorPassword;
	}

	public String login(){
		DoctorBiz doctorBiz=new DoctorBiz();
		if(doctorBiz.checkDoctorLogin(doctorNick, doctorPassword)){
			ActionContext ac=ActionContext.getContext();
			ac.getSession().put("doctorNick", doctorNick);
			return SUCCESS;
		}
		return INPUT;
	}
	
	public String doctors(){
		DoctorBiz doctorBiz=new DoctorBiz();
		List<Doctor> list=doctorBiz.allDoctors();
		if(list.size()!=0){
			ActionContext ac=ActionContext.getContext();
			ac.getSession().put("doctors", list);
			return SUCCESS;
		}
		return INPUT;
	}
	
	
	public String delDoctor(){
		DoctorBiz doctorBiz=new DoctorBiz();
		boolean b=doctorBiz.delDoctor(doctorId);
		if(b){
			return SUCCESS;
		}
		return INPUT;
	}
	
	public String addDoctor(){
		DoctorBiz doctorBiz=new DoctorBiz();
		boolean b=doctorBiz.addDoctor(doctorNick, doctorPassword, doctorName,
				departmentId, doctorWorkId, doctorSex, doctorAge, doctorPhone);
		if(b){
			return SUCCESS;
		}
		return INPUT;
	}

}
